<template>
  <div class="tc">
    <div v-for="(item, index) in titles" :key="index" :class="{active:index===currentIndex}"
    @click="handleClick(index)">
      <span>{{item}}</span>
    </div>
  </div>
</template>

<script>
  export default {
    name:'tabControl',
    props:{
      titles:{
        type:Array,
        default(){
          return []
        }
      }
    },
    data(){
      return {
        currentIndex:0
      }
    },
    methods:{
      handleClick(index){

        //this.currentIndex = index
        //传出点击的索引值
        this.$emit('tabClick',index)
      }
    }
  }
</script>

<style scoped>
  .tc{
    display:flex;
    justify-content:space-around;
    height:40px;
    line-height: 40px;
    text-align:center;
    font-size:15px;
    background-color: #fff;
  }
  .tc div{
    flex:1;
  }
  .tc div span{
    padding: 0 5px 5px 5px;
  }
  .active{

    font-weight:700;
    color:#ff5777;


  }
   .active span{

     border-bottom:3px solid #ff5777;
   }

</style>
